package com.example.appstudy2405;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);
        setContentView(R.layout.activity_main);

        findViewById(R.id.bt2guess_number).setOnClickListener(this);
        findViewById(R.id.bt2_listview).setOnClickListener(this);
        findViewById(R.id.bt2_recyview).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent intent;
        if (view.getId() == R.id.bt2guess_number) {
            Toast.makeText(this, "展示猜数字", Toast.LENGTH_SHORT).show();
            intent = new Intent(this, GuessNumber.class);
        } else if (view.getId() == R.id.bt2_listview) {
            Toast.makeText(this, "展示ListView", Toast.LENGTH_SHORT).show();
            intent = new Intent(this, BitCatP22ListView.class);
        } else if (view.getId() == R.id.bt2_recyview) {
            Toast.makeText(this, "展示RecyView", Toast.LENGTH_SHORT).show();
            intent = new Intent(this, BitCatP23RecyViewActivity.class);
        } else {
            Toast.makeText(this, "无效的跳转", Toast.LENGTH_SHORT).show();
            intent = new Intent(this, BitCatP14EditView.class);
        }
        startActivity(intent);
    }

}